/* Import plugin specific language pack */
tinyMCE.importPluginLanguagePack('icq');

var TinyMCE_IcqPlugin = {
	getInfo : function() {
		return {
			longname : 'ICQ',
			author : 'Niimai',
			authorurl : 'http://niimai.probasis.nl',
			infourl : 'http://niimai.probasis.nl',
			version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
		};
	},

	getControlHTML : function(cn) {
		switch (cn) {
			case "icq":
				return tinyMCE.getButtonHTML(cn, 'lang_icq_desc', '{$pluginurl}/images/icq.gif', 'mceIcq');
		}

		return "";
	},

	execCommand : function(editor_id, element, command, user_interface, value) {
		// Handle commands
		switch (command) {
			case "mceIcq":
				tinyMCE.openWindow({
						file : '../../plugins/icq/icq.htm',
						width : 230,
						height : 120
					}, {
						editor_id : editor_id,
						inline : "yes"
				});

				return true;
	   }

	   // Pass to next handler in chain
	   return false;
	},

	cleanup : function(type, content, inst) {
		return content;
	},

	handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
		if (node == null)
			return;

		do {
			if (node.nodeName == "IMG" && (tinyMCE.getAttrib(node, 'class') == 'icqStatus')) {
				tinyMCE.switchClass(editor_id + '_icq', 'mceButtonSelected');
				return true;
			}
		} while ((node = node.parentNode));

		tinyMCE.switchClass(editor_id + '_icq', 'mceButtonNormal');

		return true;
	},

};

tinyMCE.addPlugin("icq", TinyMCE_IcqPlugin);